package com.oss.biz;

import cn.hutool.core.lang.Validator;
import com.eova.common.base.BaseController;
import com.jfinal.aop.Before;
import com.oss.intercept.jwt.LoginInterceptor;
import com.oss.service.DealerService;
import com.oss.utils.BaseContextHandler;


public class DealerController extends BaseController {

    static DealerService dealerService = new DealerService();

//    /**
//     * 批量补充门店名称
//     */
//    public void updateName() {
//        renderJson(dealerService.updateName());
//    }


    /**
     * 经销商系列列表
     */
//    @Before(LoginInterceptor.class)
    public void getSeriesListByDealer() {
        String employeeId = BaseContextHandler.getUserID();
        if (Validator.isEmpty(employeeId)) {
            employeeId = "1";
        }
        renderJson(dealerService.getSeriesListByDealer(employeeId));
    }

    /**
     * 根据Lv获取省级别或者市份列表:0=中国,1=省,2=市,3=区
     */
    public void findListByLv() {
        Integer lv = this.getParaToInt("lv", 0);
        Integer pid = this.getParaToInt("pid", 0);
        renderJson(dealerService.findListByLv(lv, pid));
    }

    /**
     * 获取门店的省份列表
     */
    public void getProvinceList() {
        renderJson(dealerService.getProvinceList());
    }

    /**
     * 获取门店的区份列表
     */
    public void getCityList() {
        Integer provinceId = this.getParaToInt("provinceId");
        renderJson(dealerService.getCityList(provinceId));
    }


    /**
     * 根据cityId获取门店列表
     */
    public void getDealerList() {
        Integer cityId = this.getParaToInt("cityId");
        renderJson(dealerService.getDealerList(cityId));
    }

    /**
     * 获取系列列表
     */
    public void getSeriesList() {
        renderJson(dealerService.getSeriesList());
    }

    /**
     * 根据系列找门店列表
     */
    public void getDealerListBySeries() {
        Integer seriesId = this.getParaToInt("seriesId");
        renderJson(dealerService.getDealerListBySeries(seriesId));
    }
}
